<%@page import="java.awt.Button"%>
<%@page import="org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*"  pageEncoding="UTF-8"%>
<%@ page import="com.DB.*"%>
<%@ page import="com.immiinfo.model.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>全部列表</title>
<style type="text/css">
body{
background-image:url(../../image/admin_bg.png);
background-repeat:repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 1px;
margin-bottom: 0px;
font-family:Microsoft YaHei;
font-size:13px;
}
.body-div{
margin-left:10px;
}
h2{
font-family:Microsoft YaHei;
color:#fff;
margin: 5px 5px 5px 5px;
font-size:16px;
}

</style>
</head>
<body >
<h2>潜在用户列表</h2>
<div style="margin-top:10px;">

	<div style="width:auto; height:880px">

	<form name="delete" action="" method="get"> 
	  <table width="" border="0" align="center" cellpadding="0" cellspacing="0" >
	    <tr align="center" height="30"  bgcolor="#CCCCCC" >
	    <td width="50">编号</td>
	      <td width="100">姓名</td>
	      <td width="70">性别</td>
	      <td width="100">城市</td>
	      <td width="100">出生日期</td>
	      <td width="150">拟移民国家</td>
	      <td width="80">职业</td>
	      <td width="150">邮箱</td>
	      <td width="80">总分</td>
	      <td width="100">提交日期</td>
	      <td width="80">其它</td>
	      <td width="50"> <input type="submit" value="删除"  style="background-color:#CCCCCC" onclick="javascript:return deleteConfirm()" ></td>
	      <td width="50"><input type="submit" value="移除"  style="background-color:#CCCCCC" onclick="removeImportant()"></td>
	    </tr>
	    <%
	    //删除操作
	    String deleteName[];
	    String addName[];
		if(request.getParameter("ck")!=null)
		{
		 deleteName=request.getParameterValues("ck");
		 DBHelper.deletebyEmails(deleteName);
		 DBHelper.deletebyEmailsengcap(deleteName);
		 DBHelper.deletebyEmailsOthers(deleteName);
		 DBHelper.deletebyEmailsworkexp(deleteName);
		 DBHelper.deletebyEmailsskillwork(deleteName);
		 DBHelper.deletebyEmailsqua(deleteName);
		 DBHelper.deletebyEmailsparedu(deleteName);
		 DBHelper.deletebyEmailspareng(deleteName);
		 DBHelper.deletebyEmailsparwork(deleteName);
		 DBHelper.deletebyEmailsparskillwork(deleteName); 
		}
		if(request.getParameter("sure")!=null){
			addName=request.getParameterValues("sure");
			//out.print(addName);
			int addEmails[]=new int[addName.length];
			DBHelper.RemoveImportant(addName);		
		}
		//显示操作
				List<baseInfo> resultInfor=DBHelper.getImportantInfo();
				int rowCount = DBHelper.getImportantCount();//总行数
				int i =1;
				int pageSize = 25;
				int pageNow = 1;
			/* 	String temppage=request.getParameter("pageNow");
				pageNow=Integer.parseInt(temppage); */
				//默认显示第一页  s
				int pageCount = 0;//总页数  0
				String nowpage = (String) request.getParameter("pageNow");
				if (nowpage!= null) {
					pageNow = Integer.parseInt(nowpage);
				}
				if (rowCount % pageSize == 0) {
					pageCount = rowCount / pageSize;
				} else {
					pageCount = rowCount / pageSize + 1;
				}
				if(pageCount==0){
					pageCount=1;
				}
				//Iterator<showInfomation> it=resultInfor.iterator();
			//	while (it.hasNext()) {
				int beginIndex=(pageNow-1)*pageSize+1;
				if(!resultInfor.isEmpty())
				{int total;
				if(pageNow<pageCount){ total=beginIndex+pageSize;}	
				else total=rowCount-(pageCount-1)*pageSize+beginIndex;
				for(int j=beginIndex-1;j<total-1;j++)
				{
					baseInfo tempInfo=resultInfor.get(j);
					
					String name=tempInfo.getName();
					String gender=tempInfo.getGender();
					String city=tempInfo.getCity();
					String birthday=tempInfo.getDateOfBir();
					String immicountry=tempInfo.getImiCountry();
					String email=tempInfo.getE_mail();
					String admitdate=tempInfo.getadmitdate();
				 
				    List<work_experience> work_expinfo=DBHelper.getwork_experience(email);
					String work="无";
					if(work_expinfo.size()>0){
					 work=work_expinfo.get(0).getJob();
					
					}
					int tempj=j;
				    int tag=1;
					//String telnumber=tempInfo.getTelNumber();
					int score=tempInfo.getTotalscore();
					
			%>
	
			<tr align="center" height="30px">
				<td><%=j+1 %></td>
				<td><%=name%></td>
				<td><%=gender%></td>
				<td><%=city%></td>
				<td><%=birthday%></td>
				<td><%=immicountry%></td>
				<td><%=work%></td>		
				<td><%=email%></td>			
				<td><%=score%></td>
				<td><%=admitdate%></td>		
				<td width="68"><a href="/immigration/page/admin/admin_evaluation_details.jsp?EMAIL=<%=email%>&tempj=<%=tempj%>&tag=<%=tag %>">详细</a></td>
	            <td width="58"><input type="checkbox" name="ck" value=<%=email%>></td>
	            <td width="58"><input type="checkbox" name="sure" value=<%=email%>></td>
			</tr>
	<%} }%>
	  </table>
	 
	  </form>
	  <div style="margin-top:20px;" align="center">
	  <form Action="" method="post"  >
			<%
			if (pageNow != 1) {
				out.println(" <a  href=/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow=1>首页</a> ");
				out.println(" <a   href=/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow=" + (pageNow - 1)
						+ ">上一页</a> ");
			}
				//显示当前页的前三页与后三页
				for (i = ((pageNow-3)>0?(pageNow-3):1); i <= (pageCount<(pageNow+3)?pageCount:(pageNow+3)); i++) {
					out.println("<a href=/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow=" + i + ">[" + i
							+ "]</a>");
				}	
				out.print("第");
			%>
			<input type="text" name="pages" id="pages" style="width:20px" onkeydown="return jump()"   value="<%=pageNow %>"   title="按回车键将快速跳转到指定页面" />
	<% 
				out.print("/");
	%>
	<input type="text" id="total" style="width:20px" style="border:none;" value=<%=pageCount %> readonly="readonly">
	<% out.print("页");
				if (pageNow < pageCount) {
					out.println(" <a   href=/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow=" + (pageNow + 1)
							+ "> 下一页</a>");
					out.println(" <a   href=/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow=" + pageCount
							+ "> 最后一页</a>");
				}
			
				
			%>
		</form>
		</div>
	</div>
	
</div>
</body>
<SCRIPT language="JavaScript"> 
function jump()
{
	if(window.event.keyCode==13)
		{	
		var pages = document.getElementById("pages").value;//得到id为pages输入框的值
		var total= document.getElementById("total").value;//得到总页数
		
		if(pages>0&&pages<=total&&parseInt(pages)==pages)
			{
	            window.location.href = "/immigration/page/admin/admin_evaluation_showAllImportant.jsp?pageNow="+pages;
	            return false;
			}
		 else
		    {
		    	alert("您输入的页码有误！");
		    	return false;
		    }  
	      return true;
		}

}
function deleteConfirm(){
	var msg = "确定删除？";   
	if (confirm(msg)==true){   
	return true;   
	}else{   
	return false;   
	}   
	
}
function removeImportant(){
	var msg = "确定要将用户移除？";   
	if (confirm(msg)==true){   
	return true;   
	}else{   
	return false;   
	}   
}

</SCRIPT>
</html>